<template>
  <div style="align=center">
    <!-- <p>犬只检验</p> -->

    <div style="display: inline; margin-left: 3%">
      <h4 style="display: inline">犬名:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%; height: 25px"
        :disabled="true"
        v-model="dname"
      />
    </div>
    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">犬种:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%; height: 25px"
        :disabled="true"
        v-model="dtype"
      />
    </div>

    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">性别:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%; height: 25px"
        :disabled="true"
        v-model="sex"
      />
    </div>

    <!-- <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">毛色:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%; height: 25px"
        :disabled="true"
        v-model="immune_num"
      />
    </div> -->

    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">犬只体重:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4.5%; height: 25px"
        :disabled="true"
        v-model="weight"
      />
    </div>

    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">犬只肩高:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4.5%; height: 25px"
        :disabled="true"
        v-model="heigh"
      />
    </div>
    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">犬只体长:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4.5%; height: 25px"
        :disabled="true"
        v-model="longs"
      />
    </div>

    <div style="margin-top: 1%; margin-left: 3%">
      <h4 style="display: inline">出生日期:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 4.5%; height: 25px"
        :disabled="true"
        v-model="birth"
      />
    </div>

    <div style="margin-top: 3%; margin-left: 3%">
      <!-- <h4 style="display: inline">犬只正面照片:</h4> -->
      <div style="float: left">
        <el-avatar
          shape="square"
          :size="100"
          :src="full_face_photo"
        ></el-avatar>
      </div>
      <div style="margin-left: 15%">
        <el-avatar shape="square" :size="100" :src="profile_photo"></el-avatar>
      </div>
    </div>

    <!-- 核验未通过填写
    <div style="display: inline; margin-left: 3%">
      <h4 style="display: inline">犬名:</h4>
      <input
        type="text"
        style="display: inline; margin-left: 7%; height: 25px"
        :disabled="true"
        v-model="dname"
      />
    </div> -->

    <div v-show="normal ">
      <el-button
        style="float: left; margin-top: 20px; margin-left: 3%"
        type="primary"
        @click="ok"
        >核验通过</el-button
      >

      <el-button
        style="margin-left: 5%; margin-top: 20px"
        type="danger"
        @click="error"
        >核验不通过</el-button
      >
    </div>
    <div v-show="!normal ">
      <el-button
        style="margin-left: 10%; margin-top: 20px"
        type="primary"
        @click="back"
        >返回</el-button
      >
    </div>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      normal:"",
      cause: "",
      status: "",
      birth: "",
      dname: "",
      dtype: "",
      full_face_photo: "",
      profile_photo: "",
      heigh: "",
      longs: "",
      sex: "",
      weight: "",

      squareUrl:
        "https://poppyflower.oss-cn-chengdu.aliyuncs.com/2021/05/25/a38d2482-891f-4651-ada6-1388f47ac43d",
    };
  },
  methods: {
    back(){
    //     //核验不通过；返回未核验页面
          this.$router.push({ path: "/hospital/verification/for_inspect_pet" });
    },
    open() {
      this.$prompt("请输入原因", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
      })
        .then(({ value }) => {
          //   console.log(value);
          this.cause = value;
          //提交核验结果
          this.verification();
      
        })
        .catch(() => {
          this.$message({
            type: "info",
            message: "取消输入",
          });
        });
    },
    ok() {
      this.status = 2;
      this.verification();
      //核验通过就如免疫登记
      this.$router.push({
        path: "/hospital/verification/immunization_registration",
      });
    },
    error() {
      this.status = 1;
      this.open();
    },
    init() {
      // console.log(sessionStorage.getItem("rid"));
      this.$axios
        .get(
          "http://localhost:9091/immune/immune/getdogbyoid?oid=" +
            sessionStorage.getItem("rid")
        )
        .then((resp) => {
        //  console.log(resp);
          if (resp.data.code == 200) {
            (this.birth = resp.data.data.birth),
              //  (this.cause = resp.data.data.birth),
              (this.dname = resp.data.data.dname),
              (this.dtype = resp.data.data.dtype),
              (this.full_face_photo = resp.data.data.full_face_photo),
              (this.heigh = resp.data.data.heigh),
              (this.longs = resp.data.data.longs),
              (this.profile_photo = resp.data.data.profile_photo),
              (this.sex = resp.data.data.sex),
              (this.weight = resp.data.data.weight);
          } else {
            this.$message({
              type: "info",
              message: resp.data.message,
            });
          }
        });
    },
    verification() {
      console.log(this.status);
      this.$axios
        .get("http://localhost:9091/immune/immune/update", {
          params: {
            oid: sessionStorage.getItem("rid"),
            status: this.status,
            cause: this.cause,
          },
        })
        .then((resp) => {
         // console.log(resp);
          if (resp.data.code == 200) {

            this.$message({
              type: "success",
              message: "核验成功",
            });
             this.normal=false;
          } else {
            this.$message({
              type: "info",
              message: resp.data.data.message,
            });
          }
        });
    },
  },
  mounted() {
    this.init();
    this.normal=true;
  },
};
</script>
<style scoped></style>
